How to write an "if" foreign symbol condition applies then stop buy orders?

Hi. I am trying to write a command stating that if ^gspc index close is lower than previous close, for example, then buy orders of my formula will stop.
I've tried several commands but keep getting error messages.
i don't seem to know how to simply put this condition into words.
Could you help? Thanks.

You really need to use Google search.
If you searched you would find the answer to your question:

thanks. working fine. (one has to know what to Google search for...and ChatGPT gives silly suggestions).

Sorry, back again: I've used the "setforeign" function as instructed, and Amibroker indeed calculated, and i thought the problem was solved. However, the analysis results seemed suspicious to me, and i finally understood that by setting the "foreign" and restoring the arrays to my default,(setforeign ("^gspc"); RestorePriceArrays (); ) even with nothing in between, my backtest results change dramatically. (by over 90%). . as far as i understand , there should be no effect to the foreign reference, but it does. Please explain. Thanks.

@alonhalter, did you set "Pad & Align" when exploring using SetForeign? (search the forum to understand how it can affect the results).

image

In any case, to get a more precise answer, I suggest you post a formula that allows us to reproduce your problem.
Without seeing your code it's very difficult to figure out what could generate such "unexpected" results.

1 Like

Have placed a device-plus-feature request in Feedback Center, so that users be given a data-collecting device that would transmit via a TSL-secured line to the forum, something like this:


[The mind-blowing future of mind reading]

How to ask a good question remains mostly ignored! Or may be people think, their newly-sprouted idea would be lost, idk... :slight_smile:

A phrase from the Book of Ecclesiastes:

The thing that hath been, it is that which shall be,
And that which is done is that which shall be done;
And there is no new thing under the sun.

2 Likes

Yes. "Pad and Align" did the trick. I was not aware of it. And also thanks for the Ecclesiastes' citation. One of my favorite Biblical and philosophical (and, being and Israeli, i read it in the Hebrew original and enjoy also the beauty of the poetry). to sum up - solved.