Exploration in ONE row per trade with a scaleout system

Hello

I spent some time but I am unable to think how to make exploration on ONE row per trade with a scaleout system.

I would like to do some custom statistic.

In this scaleout Afl code i use VarSet() VarGet() to store the data, as I was thinking it was easy.

But how can I export the data from the Dynamic variables to exploration mode in One Row per trade and not bar by bar?

Or I would like to give me ideas how to output every single trade in ONE row with arrays or matrix or…

Sorry if this afl is to long .

scaleoutput

//Example 4: partial exit (scaling out) on profit target stops

//SetBarsRequired(-2,-2);
_N(strWeekdayGR = StrExtract("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday", SelectedValue( DayOfWeek())));
_N(Title1=Name() +","+Date()+","+ "  Timeframe: " + Interval(2)+"\n Open "+O +", High " +H +", Low "+L +", Close "+C+ ", "+"(" +WriteVal(ROC(C,1),1.2)+"%)"  +", Spread " + WriteVal((H-L)/TickSize ,1)) ;
_N(Title=" # "+strWeekdayGR+" #  "+Title1 +"\n System:  "+  StrExtract( StrExtract( GetFormulaPath(), -1, '\\' ), -2, '.' ));
EnableTextOutput(0);
Title += "\n                                  L 1st  Open + (ATR(14)*3)  = " + NumToStr( SelectedValue(O)+(ATR(14)*3),1.2) ;
Title += "\n                                  L 2nd Open + (ATR(14)*4)  = " + NumToStr( SelectedValue(O)+(ATR(14)*4),1.2) ;
Title += "\n                                  S 1st  Open - (ATR(14)*3)  = " + NumToStr( SelectedValue(O)-(ATR(14)*3),1.2) ;
Title += "\n                                  S 2nd Open - (ATR(14)*4)  = " + NumToStr( SelectedValue(O)-(ATR(14)*4),1.2) ; 
    CandleColor = IIf( C > O, colorGrey50, colorDarkRed ); // εξωτερικό χρώμα κεριών.
    Plot( C, "Price", CandleColor, styleCandle );
EnableTextOutput(1);

/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// Start Strategy ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

ema200 = EMA( C, 200 );
Plot( EMA( C, 200 ), _DEFAULT_NAME(),colorOrange, styleNoRescale|styleDots );

// ========  συνθήκη ανοδικό βέλος
kmo200 = L > EMA(C,200);  // close > ema 200

kmo20 = EMA(C,20);
kmo50 = EMA(C,50);
Plot( kmo20, "kmo20", colorOrange, styleLine );
Plot( kmo50, "kmo50", colorBlue, styleLine );


COND_UP_ARROW =  Cross(kmo20,kmo50) AND  L > EMA(C,200);  
//COND_UP_ARROW = Ref(COND_UP_ARROW,-1);
PlotShapes(IIf(COND_UP_ARROW, shapeUpArrow, shapeNone), 34,0,L, -90); 
// ========  συνθήκη πτωτικό βέλος
cond01dn =   H < EMA(C,200);

COND_DN_ARROW = Cross(kmo50,kmo20) AND  H < EMA(C,200); 
PlotShapes(IIf(COND_DN_ARROW, shapeDownArrow, shapeNone), 9,0,H, -80); 
_SECTION_END();
////////////////////////////////////////////////////////////////////
////////////////////////////////// End of Strategy //////////////////
/////////////////////////////////////////////////////////////////////
// Path to save the CSV file
SYS="KMO";
PathToSave = "R:\\TEMP\\";		//<<<  Path to save the CSV file
FileName = SYS+"_praxisBacktestFH.csv";

/////////////////////////////////  GuiButton /////////////////////////
GuiButton( "DebugView", 99, Status( "pxwidth" )-100, 40, 80, 24, 7 );
id = GuiGetEvent( 0, 0 ); 	event = GuiGetEvent( 0, 1 );  DebugOn=0;
if( id == 99 && event == 1 ) {DebugOn=1; GuiSetText("Debug clicked",99); }
//if(DebugOn) 	_TRACE("#, Message = " + msgid);

GuiButton( "writeTXT", 98, Status( "pxwidth" )-100, 60, 80, 24, 7 );
 writeTXT=0;   writeTXTs=0;
if( id == 98 && event == 1 ) {writeTXT=1; GuiSetText("DONE",98); Say("1");}

/////////// GuiTriger - 2 Lines ///////////////
GuiToggle("Delete file", 97, Status( "pxwidth" )-100, 80, 80, 24, 7 );
if( GuiGetCheck( 97 )) { fdelete(PathToSave + FileName); GuisetCheck( 97,0); Say("del");}


/////////////////////////////////  FUCTION to write TXT ////////////////////////////
_SECTION_BEGIN("For exploration Only Write the Trades to CSV");  
if( ParamToggle("Write the LONG trades","Stop Writing|Write Now",0) ) writeTXT=1;
if( ParamToggle("Write the SHORT trades","Stop Writing|Write Now",0) ) writeTXTs=1;
dt=DateTime();
Ticker=Name();
function AppendTradeToFile( Action ) // Action = "Buy", "Sell", etc.
{
    global Ticker;
          //fputs( "Ticker, ID , BIndex, BUY, 1stProfit, 1ndProfit, Trail , StopLoss \n", fh );
    TradeString = Ticker +","+ Interval( 2 )+ "," + Action + "," + "\n";
    _TRACE( "# " + TradeString ); // Optional for debugging
    fh = fopen( PathToSave + FileName, "a", true );  // επισυνάπτει νεες γραμμες ,  "True" is to allow shared access to the file from multiple threads.

    if( fh )
    {
        fputs( TradeString, fh );
        fclose( fh );
    }

    return fh > 0; // returns True if file was opened successfully.
}
_SECTION_END();


//////////////////////////////////////////////////////////////////////////////
/////////////////////     Τrade Hours      //////////////////////////////////
_SECTION_BEGIN("Backtest TradeTime - with Time"); 

tn = TimeNum();
StartTime = ParamTime( "Start Time", "9:30" );
EndTime = ParamTime( "End Time", "23:00" );
TimeOK = tn >= StartTime AND tn <= EndTime;
ExitTime = Cross( tn, EndTime );

TradeTime=ParamToggle(" backTest with Hours?", "No|Yes",0 ) ;
if( TradeTime )
{
    //----- Buy, Sell, Short, Cover,  With TradeTime
    Buy = Ref( COND_UP_ARROW, - 1 ) AND TimeOK;
    Short = Ref( COND_DN_ARROW, -1 ) AND TimeOK; 		// delay 1 bar
    TitleTradeTime = "\nBacktest TradeTime -With Hours";
    Plot( TimeOK, "", ColorRGB( 40, 0, 0 ), styleArea | styleOwnScale, 0, 1, 0, -4 );
}
else
{
    //-----  Buy, Sell, Short, Cover, with NOT TradeTime
    Buy = Ref( COND_UP_ARROW, - 1 );
    Short = Ref( COND_DN_ARROW, -1 ); 		// delay 1 bar
    TitleTradeTime = "\nBacktest TradeTime - Without Hours";
}
_SECTION_END();

//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// the system will Buy 3 Contracts
// then will exit if:
// 1/3 of position if FIRST PROFIT TARGET stop is hit 
// 1/3 of position is SECOND PROFIT TARGET stop is hit
//     Rest of the position if TRAILING STOP is hit
// 100% of position if TRAILING STOP is hit
// 100% of position if STOP is hit 

Sell = Cover = 0; 

FirstProfitTarget = (ATR(14)*3); 	// point
SecondProfitTarget = (ATR(14)*4); 	// point
StopAtr = (ATR(14)*1.5);			// point
StopLossAdjustL= StopLossAdjustS=0;

priceatbuy = priceatShort= 0; priceatbuyarray=0;

FirstProfitTargetL = SecondProfitTargetL = FirstProfitTargetS = SecondProfitTargetS = 0;
StopLoss=StopLoss=0;
priceatShortProfit = priceatSecondProfit = priceatShortStop= 0 ; 

exit = 0; 
BuyPrice= Open;   // Το Σημείο αγοράς
ShortPrice= Open;
ShowPrice= ParamToggle( "LONG Text Τarget,Stop", "Plot| No plot" );
ShowPriceS= ParamToggle( "SHORT Text Τarget,Stop", "Plot| No plot" );


//////////////  Trailing Stop % //////////////////////
/// @link http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/
StopNum = Param("Trailing Stop %", 1.10, 0.20, 10, 0.01);
StopLevelLong = 1 - (StopNum /100);    // StopLevelLong =  1 - (0.2/100) = 0.998
StopLevelshort = 1 + (StopNum /100);
trailARRAYLong = trailARRAYShort= Null;
TrailStopLong = TrailStopShort = 0;
//////// END   Trailing Stop % //////////////////////

//////////// Counters for Statistika //////////////////////////
CntBuys = CntShort = 0; 	//  how many times we had Long Trades?
sta = sta1 = sta2 =stop = trail = ex1= ex2 =0;
pipL = pipS = 0;  		// Pips for long and short 			
cuntStopL= cuntStopS= cunt1StopL= cunt1StopS= cunt2StopL= cunt2StopS=0;
cuntTrailL= cunt1TrailL= cunt2TrailL= cuntTrailS= cunt1TrailS= cunt2TrailS=0;
////////END //// Statistika //////////////////////////

bi= BarIndex();
dn = DateNum();

for( i = 0; i < BarCount; i++ )
{

    if( priceatbuy == 0 AND TrailStopLong == 0 AND TrailStopShort == 0 AND Buy[ i ] ) 
    {
        priceatbuyarray[i] = BuyPrice[ i ];
        priceatbuy = BuyPrice[ i ];	
        StopLoss = StopAtr[i];
        FirstProfitTargetL = priceatbuy + FirstProfitTarget[i];
        SecondProfitTargetL = priceatbuy + SecondProfitTarget[i];
        StopLossAdjustL = priceatbuy ;   	//  Adjust StopLoss to brake even after the first scaleout
        TrailStopLong = High[ i ] * StopLevelLong;
		
		CntBuys++;  // Buy Counter
        if( ShowPrice ) PlotText( "__(" + CntBuys + ")_Buy " +  priceatbuy [ i ] , i, BuyPrice[ i ], colorBrightGreen );

 		VarSet("buyPr"+i,priceatbuy );  sta=VarGet("buyPr"+i);	
		if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ",  0 BUY,\t"+priceatbuy + "," + ",,,,,");

    }


    if( priceatbuy > 0 )
    {

        if( exit == 0 AND  High[i] >=  FirstProfitTargetL )
        {
            // first profit target hit - scale-out
            exit = 1;	           
            Buy[i] = sigScaleOut;
            Buyprice[i] =  FirstProfitTargetL;  //It is Buy signal to scale out so

			VarSet("SBuyPrice", BuyPrice[i]);
            if( ShowPrice )  PlotText( "_(" + CntBuys + ")_Exit  " + exit + " target\n@" + Buyprice[ i ], i, Buyprice[ i ], colorWhite, colorGrey40 );
			VarSet("buy1"+i,Buyprice[i]);	sta1=VarGet("buy1"+i);  VarSet("buy1C_"+CntBuys ,Buyprice[i]);
			if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 1st Pft,,"+sta1+ ","+ ",,,,");			

        }



         if( ( exit == 1) AND High[ i ] >= SecondProfitTargetL )  
        {
            // second profit target hit - exit
            exit = 2;
            Buy[i] = sigScaleOut;
			Buyprice[ i ] =   SecondProfitTargetL ;

			if( ShowPrice ) PlotText( "_(" + CntBuys + ") Exit  " + exit + " target\n@" + Buyprice[ i ], i, Buyprice[ i ], colorWhite, colorGrey40 );
			VarSet("buy2"+i,Buyprice[i]);	 sta2=VarGet("buy2"+i);		VarSet("buy2C_"+CntBuys ,Buyprice[i]);
			if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 2nd      ,,,      "+sta2+ ","+ ",,,");
        }



		////////////////EXIT 3 STOP LOSS /////////////////////
        if( (exit == 0 ) AND Low[ i ] <= priceatbuy - StopLoss[i] )	// Εάν δεν υπάρχει ΕΧΙΤ ακομη (δηλαδή ΕΧΙΤ =μηδέν) και κτυπήσει το Στοπ τοτε?.
        {
            // stop Long hit - exit
            exit = 3;
            SellPrice[ i ] =   priceatbuy - StopLoss[i]  ;		// δήλωσε τιμές την τιμή εξόδου Stop

			VarSet("Stop"+i,SellPrice[i]);	   Stop[i] =VarGet("Stop"+i);   ex3=(Stop-sta)*3;
			VarSet("AddPipl"+i,ex3);  PipL=VarGet("AddPipl"+i)+PipL;
			cuntStopL++;
            if( ShowPrice )  PlotText( "_(" + CntBuys + ") Exit " + exit + " Stop \n@" + SellPrice[ i ] + "\nPL:  "+NumToStr(ex3,1.2), i, SellPrice[ i ], colorWhite, colorRed );
			if(writeTXT) { Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop ,"+sta + ",0 "+ ",0 " + ",0, " + Stop+ ",,,"+NumToStr(ex3,1.2)+ ",Sum ," + PipL + ", cuntStopL= "+ cuntStopL; 		AppendTradeToFile( Action ); }
			if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop   , \t"+sta + "\t,0 \t\t"+ "\t,0 \t\t" + "\t,0, \t\t" + Stop+ ","+ ",,\tPL = , " +NumToStr(ex3,1.2));
        }

		// if we had 1 profit, then use the StopLossAdjust as a stop.
        if(  exit == 1 AND Low[ i ] <= StopLossAdjustL[i] )    //Adjust the StopLoss to brake even 
        {
            // stop Long hit - exit  + there is 1 profit and then Stop 
            exit = 3;
            SellPrice[ i ] =   StopLossAdjustL[i];

			VarSet("Stop"+i,SellPrice[i]);		
			Stop =VarGet("Stop"+i);		ex1=sta1-sta;  ex3=(Stop-sta)*2;
			VarSet("AddPipl"+i,ex1+ex3);  PipL=VarGet("AddPipl"+i)+PipL;
			cunt1StopL++;
			if( ShowPrice )  PlotText( "_(" + CntBuys + ") Exit +1st " + exit + " Stop \n@" + SellPrice[ i ]+ "\nPL:  "+NumToStr(ex1+ex3,1.2), i, SellPrice[ i ], colorWhite, colorRed );
			if(writeTXT) { Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop+1 ,"+sta + ", "+sta1+ ",0 " + ",0, " + Stop+ ",,,"+NumToStr(ex1+ex3,1.2)+ ",Sum ," + PipL +  " StopLoss[i] "+ (priceatbuy - StopLoss[i]) + " StopLossAdjustL "+ StopLossAdjustL[i]; 		AppendTradeToFile( Action ); }
			if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop+1 \t,"+sta + ", "+sta1+ ",0 " + ",0, " + Stop+ ","+ ",\t,\tPL =  , "+NumToStr(ex1+ex3,1.2));
        }

		// there was second profit target and then Stop hit.  
        if(  exit == 2 AND Low[ i ] <= StopLossAdjustL[i] )    // Adjust the StopLoss to brake even 
        {
            // stop Long hit - exit +  2 profit then Stop .
            exit = 3;
            SellPrice[ i ] =   StopLossAdjustL[i];  

				VarSet("Stop"+i,SellPrice[i]);	 Stop =VarGet("Stop"+i);		  ex1=sta1-sta; ex2= sta2-sta; ex3=stop-sta;
				VarSet("AddPipl"+i,ex1+ex2+ex3);  PipL=VarGet("AddPipl"+i)+PipL;
				cunt2StopL++;				
				if( ShowPrice )  PlotText( "_(" + CntBuys + ") Exit +2st " + exit + " Stop \n@" + SellPrice[ i ] + "\nPL:  " + NumToStr(ex1+ex2+ex3,1.2) , i, SellPrice[ i ], colorWhite, colorRed );
				if(writeTXT) { Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop+2 ,"+sta + ", "+sta1+ ", "+sta2 + ",0, " + Stop+ ",,,"+NumToStr(ex1+ex2+ex3,1.2) + ",Sum ," + PipL; 		AppendTradeToFile( Action ); }
				if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 3 Stop+2 ,"+sta + ", \t"+sta1+ ", \t"+sta2 + ",0\t, " + Stop+ ","+ ",\t,\tPL = , "+ NumToStr(ex1+ex2+ex3,1.2) +"=\t(" + ex1+"\t" + ex2 + "\t" + ex3+")");
        }
	


		///////////////////////////////////////////////////////////////////////////////////////////////////
		//  EXIT 4 TrailStopLong  scale out with below ways
		///////////////////////////////////////////////////////////////////////////////////////////////////
		if( NOT exit == 3 )  	// if not Stoposs  hit
		{

			if( NOT exit == 4 AND exit == 2 AND TrailStopLong > 0 AND Low[ i ] < TrailStopLong)  	// if 1st Profit and TrailStopLong
			{
			// if 2nd Profit and TrailStop Long  hit - exit
			exit = 4;
			SellPrice[ i ] = TrailStopLong;

			VarSet("trail"+i,SellPrice[i]);	 trail =VarGet("trail"+i);   ex1=sta1-sta; ex2= sta2-sta; ex3=trail-sta;
				VarSet("AddPipl"+i,ex1+ex2+ex3);  PipL=VarGet("AddPipl"+i)+PipL;
				cunt2TrailL++;
				if(ShowPrice) PlotText( "_(" + CntBuys + ")_TRL ST " +  SellPrice[ i ] + "\nPL:  " + NumToStr(ex1+ex2+ex3,1.2), i, SellPrice[ i ], colorRed );
				if(writeTXT) { 	Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail 2nd, "+sta + ", "+sta1+ ", "+ sta2 + ", "+ trail + ","+",,,"+NumToStr(ex1+ex2+ex3,1.2)+ ",Sum ," + PipL; 		AppendTradeToFile( Action ); }
				if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail-2nd  , \t"+ 0 + ", \t"+ex1+ ", \t"+ ex2 + ", \t"+ ex3 + ","+ ",,\tPL = , "+NumToStr(ex1+ex2+ex3,1.2));

			}
			
			if( NOT exit == 4 AND  exit == 1 AND TrailStopLong > 0 AND Low[ i ] < TrailStopLong )  	// if 1st Profit and TrailStop Long  hit - exit
			{
			// if 1st Profit and TrailStop Long  hit - exit
			exit = 4;
			SellPrice[ i ] = TrailStopLong;

				VarSet("trail"+i,SellPrice[i]);	 trail =VarGet("trail"+i);   ex1=sta1-sta;  ex3=(trail-sta)*2;
				VarSet("AddPipl"+i,ex1+ex3);  PipL=VarGet("AddPipl"+i)+PipL;
				cunt1TrailL++;
				if(ShowPrice) PlotText( "_(" + CntBuys + ")_TRL ST " +  SellPrice[ i ] + "\nPL:  " + NumToStr(ex1+ex3,1.2), i, SellPrice[ i ], colorRed );
				if(writeTXT) { 	Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail 1st, "+sta + ", "+sta1+ ", " + ", "+ (trail*2) + ","+",,,"+NumToStr(ex1+ex3,1.2)+ ",Sum ," + PipL; 		AppendTradeToFile( Action ); }
				if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail-1st  , \t0"+  ", \t" +ex1+ ", \t0"+  ", \t"+ ex3 + ","+ ",,\tPL = , "+NumToStr(ex1+ex3,1.2));

			}

		// TrailStopLong hit - witout any profit target
			if( NOT exit == 4 AND TrailStopLong > 0 AND Low[ i ] < TrailStopLong ) 
			{
			// trailing stop hit - exit
			exit = 4;
			SellPrice[ i ] = TrailStopLong;
				
				VarSet("trail"+i,SellPrice[i]);	 trail =VarGet("trail"+i);    ex3= (trail-sta)*3;
				VarSet("AddPipl"+i, ex3);  PipL=VarGet("AddPipl"+i)+PipL;
				cuntTrailL++;
				if(ShowPrice) PlotText( "_(" + CntBuys + ")_TRL ST " +  SellPrice[ i ] + "\nPL:  " + NumToStr(ex3,1.2), i, SellPrice[ i ], colorRed );
				if(writeTXT) { 	Action ="Long,"+DateTimeToStr( dt[i] )+",,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail, "+sta + ", "+ ", "+ ", "+ trail + ","+",,,"+NumToStr(ex3,1.2) + ",Sum ," + PipL; 		AppendTradeToFile( Action ); }
				if(DebugOn)  _TRACE("#,"+CntBuys +",bi "+ bi[i]+ ", 4 Trail  , "+sta + ", \t"+ ",0 \t"+ ",0 \t"+ trail + ","+ ",,\tPL = , "+NumToStr(ex3,1.2));

			}

		}


        if( TrailStopLong > 0 )
        {
            TrailStopLong = Max( High[ i ] * StopLevelLong, TrailStopLong );
            trailARRAYLong[ i ] = TrailStopLong;
        }

        if( exit >= 3 )   
        {
            Buy[ i ] = 0;
            Sell[ i ] = exit ; // ονοματίζουμε τον λόγο από τον οποίο έγινε το exit
            exit = 0;
            priceatbuy = 0; // reset price
            TrailStopLong = 0;
        }
    }

} 

ExitStopLong =  Ref(trailARRAYLong,-1);
//ExitStopShort = Ref(trailARRAYshort,-1);



bi=BarIndex();
bir = Status("BarInRange");

if( Status( "Action" ) == actionExplore )
{
    Filter = Sell; // OR cover;

    for( i = 1; i < BarCount; i++ )
    {
        if( bir[i] ) //Check whether element is within set analysis range
        {
            // all below are Prices
            sta[i] = VarGet( "buyPr" + i );	// buy Price
            sta1[i] = VarGet( "buy1" + i ); //1 profit
            sta2[i] = VarGet( "buy2" + i );	//2 profit
            Stop[i] = VarGet( "Stop" + i );
            trail[i] = VarGet( "trail" + i );
        }
    }


    AddColumn( IIf( Sell, Asc( "B" ), Asc( "S" ) ), "Pos", formatChar );
    AddColumn( bi, "Barindex", 1 );

    AddColumn( sta, "Buy price", 1.2 );
    AddColumn( Sta1, "Sta1-Profit", 1.2 );
    AddColumn( sta2, "sta2-Profit", 1.2 );
    AddColumn( trail, "trail price", 1.2 );    
    AddColumn( stop, "stop ", 1.2 );
    AddColumn( PipL, "Pips Per Trade", 1.2 );


}





//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////

if( Status( "Action" ) == actionIndicator )
{
    Plot( C, "Price", colorDefault, styleCandle );  // πρεπει τα καντιλια να ειναι πανω απο το trailingStop
    Plot( trailARRAYLong, "trailing stop LongLevel", colorGreen,styleLine|styleNoRescale);
    Plot( trailARRAYShort, "trailing stop ShortLevel", colorRed,styleLine|styleNoRescale );

}


if( Status( "ActionEx" ) == actionBacktest )
{
    Lots = 3;
    SetTradeDelays( 0, 0, 0, 0 );					// delay entry/exit by one bar

    SetOption( "FuturesMode", True );
    SetOption( "AllowSameBarExit" , True );  		// If this option is not set true positions that are exited at the same bar remains Open
    SetOption( "MaxOpenPositions", Lots );
    SetOption( "ActivateStopsImmediately", True );
    SetOption( "ExtraColumnsLocation", 1 );
    SetOption( "AllowPositionShrinking", false );
    SetPositionSize( Lots, spsShares ); 			// 3  three contracts with every entry signal
    SetPositionSize( 100 / Lots, IIf( Buy == sigScaleOut, spsPercentOfPosition, spsNoChange ) ); // for scale-out use 33% of current position size

    PositionSize = Ref( PositionSize, -1 ); // If using non-zero Trade Delays with scaling in/out  (use this line)
}

PS I have already made already one sample output with addRow below foto.

addrow

Thank you.

There isn't any AddRow line in "your" code.


But if you are asking why upper columns Sta1* and sta2* are empty...
It is because your Filter uses Sell only but scale signals are assigned to Buy!
So obviously your would have to add recognition of scaleouts to Filter too.

Filter = Sell OR Buy == sigScaleOut; // OR cover;

35

1 Like

Hi @fxshrat
Thank you for your time.

i did wrote with this way the Filter = Sell OR Buy == sigScaleOut OR Buy;
But as many recognitions we add to the filter, We can not achieve the result to be only in One line as i wish to be the output in exploration.

as for your Question about the AddRow i try to minimize this Afl so i dind include, But i use all the Counters from the present afl file.

image

Who is we?

Do you mean we here in general with AB?
Or you and some other there?
Is it commercial request by someone and you can get further?

Anyway....
As you can see I can (without Addrow).

36

Your problem is that you use (different) i (bar index).
You should not use different one.
You should use something else stored at entry.

Yes i note this one more time in my life. :face_exhaling:
I usually had a problem people to understand me, when I try to speak polite in my translation form Greek to English. ( But i cannot solve it it is my habit.)

In Greek we speak in plural when we like to speak very polite. :wink:
Any way I have to buy a beer for you.

1 Like

it is for my personal use

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.