Hello community,
I have a script as shown below, i intend the script to be using current price and an indicator(EMA) in my case. The barperiod is 1440. i would like the script to enter a trade without waiting for the current running bar to be closed as it is not using priceclose but the current price. i would also like the script to exit the trade when the indicator crosses the price on opposite direction. the script is below and attached is what i intend the script to be doing. The white line is the indicator whereas the other line is the price(AUDUSD) in my case. Kindly help on how to update the script to produce the desired script....

I like Zorro Though, ...


function run()
{
StartDate = 2011;
EndDate = 2018;
set(TICKS);
Lots = 300;
BarPeriod = 1440;
LookBack = 150;
MaxLong = 1;
MaxShort = 1;

Stop = 50*PIP;
Trail = 1.5*ATR(14);
//TrailLock = 1;


vars EMA7 = series(EMA(Close, 7));
vars Price = series(price());

if(Price[0] > EMA3[0])
enterLong();
//if(Close[0] < Close[2])
//exitLong()

if(Price[0] < EMA3[0])
enterShort();
//if(Close[0] Close[])
//exitShort

plot("EMA3", EMA3[0], 0, BLUE);

set(PLOTNOW);
PlotWidth = 1200;
PlotHeight1 = 350;
}

Attached Files PRICE AND INDICATOR.PNG