Need help_ExRem_Amibroker

#1
I have written a strategy with buy, sell, short and cover signals.

I wish to have only those sell signals corresponding to already generated buy signals, and similarly for short signals ( wish to have only those cover signals corresponding to already generated short signals)

But the outcome is very not as per my requirement, it is showing standalone sell signals for which no buy signal has ever been generated.
The code snippet is as follows:

Buy=Condition 1 AND Condition 2
Sell=Condition 1 AND Condition 2
Short=Condition 1 AND Condition 2
Cover=Condition 1 AND Condition 2

Buy = ExRem( Buy, Sell );
Short=ExRem(Short,Cover);


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
 
#2
It can be done as follows.Further refinements might be needed to have a better queuing system among orders.




buyopen=0;
shortopen=0;

for (i = 0; i < BarCount ; i++) {
if(Condition 1 AND Condition 2 AND buyopen==0)
{Buy[i] = 1; buyopen=1;}
if(Condition 1 AND Condition 2 AND buyopen==1)
{Sell[i] = 1; buyopen=0;}
if(Condition 1 AND Condition 2 AND shortopen==0)
{Short[i] = 1; shortopen=1;}
if(Condition 1 AND Condition 2 AND shortopen==1)
{Cover[i] = 1; shortopen=0;}
}

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
 

asnavale

Well-Known Member
#3
It can be done as follows.Further refinements might be needed to have a better queuing system among orders.




buyopen=0;
shortopen=0;

for (i = 0; i < BarCount ; i++) {
if(Condition 1 AND Condition 2 AND buyopen==0)
{Buy[i] = 1; buyopen=1;}
if(Condition 1 AND Condition 2 AND buyopen==1)
{Sell[i] = 1; buyopen=0;}
if(Condition 1 AND Condition 2 AND shortopen==0)
{Short[i] = 1; shortopen=1;}
if(Condition 1 AND Condition 2 AND shortopen==1)
{Cover[i] = 1; shortopen=0;}
}

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

You are using same condition for Buy and Sell (Buy = Condition AND Condition 2; Sell= Condition AND Condition 2). Therefore, the last condition which is true will persist. In your case the first condition for Buy is nullified by the next condition for Sell and the Sell persists.
 
#4
Please check the original post. Exact conditions were not specified. Condition AND Condition 2 is just placeholder. It should be replaced by correct Boolean conditions.
 
#5
It can be done as follows.Further refinements might be needed to have a better queuing system among orders.




buyopen=0;
shortopen=0;

for (i = 0; i < BarCount ; i++) {
if(Condition 1 AND Condition 2 AND buyopen==0)
{Buy[i] = 1; buyopen=1;}
if(Condition 1 AND Condition 2 AND buyopen==1)
{Sell[i] = 1; buyopen=0;}
if(Condition 1 AND Condition 2 AND shortopen==0)
{Short[i] = 1; shortopen=1;}
if(Condition 1 AND Condition 2 AND shortopen==1)
{Cover[i] = 1; shortopen=0;}
}

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
It can be done as follows.Further refinements might be needed to have a better queuing system among orders.




buyopen=0;
shortopen=0;

for (i = 0; i < BarCount ; i++) {
if(Condition 1 AND Condition 2 AND buyopen==0)
{Buy[i] = 1; buyopen=1;}
if(Condition 1 AND Condition 2 AND buyopen==1)
{Sell[i] = 1; buyopen=0;}
if(Condition 1 AND Condition 2 AND shortopen==0)
{Short[i] = 1; shortopen=1;}
if(Condition 1 AND Condition 2 AND shortopen==1)
{Cover[i] = 1; shortopen=0;}
}

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

Thanks!! very helpful
 
#6
It can be done as follows.Further refinements might be needed to have a better queuing system among orders.




buyopen=0;
shortopen=0;

for (i = 0; i < BarCount ; i++) {
if(Condition 1 AND Condition 2 AND buyopen==0)
{Buy[i] = 1; buyopen=1;}
if(Condition 1 AND Condition 2 AND buyopen==1)
{Sell[i] = 1; buyopen=0;}
if(Condition 1 AND Condition 2 AND shortopen==0)
{Short[i] = 1; shortopen=1;}
if(Condition 1 AND Condition 2 AND shortopen==1)
{Cover[i] = 1; shortopen=0;}
}

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

But the condition 1 and other conditions are in the form of arrays, IF function only accepts binary conditions? what other function can i use
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?