Amibroker / Only trade the first signal in row / buy->sell->buy->sell->buy->sell->buy->sell etc...

#1
Hello Friends!

My automated trading works as follows: Amibroker sends signals via IBControler and then TWS sends the orders on the market.
But I have to many signals in the row.

Now it works like this for example (minute candle): buy, buy, buy, sell, sell, sell, sell, buy, sell, sell, buy, sell, buy, sell, buy, buy, buy, sell, sell

But I want to improve like this (minute candle): buy, sell, buy, sell, buy, sell, buy, sell, buy, sell,

Can you help me please?





5678.jpg




This is my AFL:

Buy = Close>Ref(Close,-10);
Sell = Close<Ref(Close,-10);


if( LastValue( Buy ) )
{
ibc = GetTradingInterface("IB");

// check if we are connected OK
if( ibc.IsConnected() )
{

// transmit order
ibc.PlaceOrder( "ALE-WSE-STK-PLN", "Buy", 200, "MKT", 0, 0, "Day", True );

}
}



if( LastValue( Sell ) )
{
ibc = GetTradingInterface("IB");

// check if we are connected OK
if( ibc.IsConnected() )
{

// transmit order
ibc.PlaceOrder( "ALE-WSE-STK-PLN", "Sell", 200, "MKT", 0, 0, "Day", True );

}
}

Short = Sell;
Cover = Buy;
 
#2
On another thread you have said that you think EXREM does not work

you can try this

Buy01 = Close>Ref(Close,-10);
Sell01 = Close<Ref(Close,-10);

Buy = Buy01 and Not (ref(Buy01,-1);

same for Sell