How to define a global variable which can be used across Buy/Sell scripts and Long Exit/Short Exit scripts?

Hi

I want to use the following code in BackTesting.

Buy Script:

SET SMA50_BUY = SMA( CLOSE, 50 )

SET BUY_PRICE = IF( CLOSE > SMA50_BUY, CLOSE, 0 )

But I am not able to use this BUY_PRICE in "Long Exit" script.

And vice-versa in case of "Sell" and "Sell Exit" scripts also.

Here I need to define these BUY_PRICE and SELL_PRICE as global variables, Am I correct ?

If so, how to define them as global variables to use across ?  

Thanks,

Ravi

hElLO tRaDeR,

Trade alerts in Pi are generated using conditions based on candlestick values and REF functions.

You cannot SET a fixed global candle variable across your strategy.

Candlestick can be referenced with the REF function, as new candlesticks are formed the REF argument on the earlier candle changes.

Your modified BUY SCRIPT:

CLOSE > SMA(CLOSE,50)

Generates a BUY SIGNAL when the close price of the recent candle is greater than SMA of 50 recent candles.