Attempting to create a signal that uses two data streams of the same symbol. Data1 is time. Data2 is renko.
The idea requires that there be one entry per data2 bar created, directly proceeding the closure of the data2 bar, I believe this means the actual trade would occur at the closure of the very next data1 bar, correct? All calculations should be based upon data2, except for the actual entry/exit trade which requires use of data1.
I think I am missing a basic concept somewhere in here. I've tried counting bars based upon barstatus change, however, my commentary is clearly showing that's not coded correctly (so did not add it as an entry signal requirement). I am both way off in counting data1 bars after a completed data2 bar, just counting data2 bars in general, and how to accomplish the original idea of just one entry directly after a formed data2 bar and not allowing a trade to occur until that data2 bar forms after an exit of a trade.
Requesting assistance from the community to please advise of an easier, and successful way to accomplish this goal.
I would think that just a simple:
Code: Select all
if barstatus(2) = 2 then begin barcount = barcount + 1 ; end ;
Sample code, that does not work successfully, to trade only after a data2 bar is as below:
Code: Select all
inputs: Quantity ( 1 ) , __PRICECHANNEL__ ( "PriceChannel" ), PC_ENTRY_ONOFF ( 1 ) , PCEntrylength ( 10 ),
ProfitTargetAmt ( 100), StopLossAmt ( 50 ) ;
variables:
{PRICE CHANNEL} HIGHESTHIGHSIGNAL ( 0 ), LOWESTLOWSIGNAL ( 0 ), PcUpperBand ( 0, data2 ), PcLowerBand( 0, data2 ), Price ( 0, data2 ) ,
{barcount} barcount ( 0 ) ;
Price = Close data2;
PcUpperBand = Highest( High data2, PCEntrylength )[1] data2; PcLowerBand = Lowest( Low data2, PCEntrylength )[1] data2;
IF PC_ENTRY_ONOFF = 0 then begin HIGHESTHIGHSIGNAL = 1; LOWESTLOWSIGNAL = 1; end
else if PC_ENTRY_ONOFF = 1 then BEGIN
if Price > PcUpperBand then begin HIGHESTHIGHSIGNAL = 1 ; end else HIGHESTHIGHSIGNAL = 0;
IF Price < PcLowerBand then begin LOWESTLOWSIGNAL = 1 ; end else LOWESTLOWSIGNAL = 0; end ;
if HIGHESTHIGHSIGNAL = 1 then begin Buy ( "LONG" ) Quantity shares THIS bar CLOSE; end ;
if LOWESTLOWSIGNAL = 1 then begin SellShort ( "SHORT" ) Quantity shares THIS bar CLOSE ; end ;
if ProfitTargetAmt > 0 then SetProfitTarget( ProfitTargetAmt ) ;
SetStopPosition ; if StopLossAmt > 0 then SetStopLoss( StopLossAmt ) ;
if barstatus(2) = 2 then begin barcount = 0 ; end ;
if barcount = 0 then begin barcount = barcount + 1 ; end ;
if AtCommentaryBar then begin CommentaryCl( "PcUpperBand : ", PcUpperBand ) ;
CommentaryCl( "PcLowerBand: ", PcLowerBand) ; CommentaryCl( "Price : ", Price ) ; CommentaryCl( "barstatus(1): ", barstatus(1)) ;
CommentaryCl( "barstatus(2): ", barstatus(2)) ; CommentaryCl( "barcount : ", barcount ) ; end ;