Foreign with import wizard csv files

Dear team, when I am mapping field prices with import wizard csv files, found Overlap data values, when I use afl foreign function.

IS there any way to use foreign function with import wizard data which mapped with field prices.

TickerExtopen      = Foreign    ( Name()+" FLOW" , "O" );  
TickerExthigh       = Foreign    ( Name()+" FLOW" , "H" );
TickerExtlow         = Foreign    ( Name()+" FLOW" , "L" );
TickerExtclose      = Foreign    ( Name()+" FLOW" , "C" );
TickerExtopenInt   = Foreign    ( Name()+" FLOW" , "I" );
TickerExtvolume   = Foreign    ( Name()+" FLOW" , "V" );






Don't do that this way. Foreign is a heavy function. You should call it only if you need ONE field. If you need more use SetForeign instead as single call allows you to get all fields

SetForeign( Name() + " FLOW" );
TickerExtopen      = O;
TickerExthigh       = H;
TickerExtlow         = L;
TickerExtclose      = C;
TickerExtopenInt   = OpenInt; 
TickerExtvolume   = V;
RestorePriceArrays();
1 Like

Dear Tomasz, thanks for counting support us
when I use your process don't return the correct data value also, I mean found the same issue, so is there any issues when I use foreign afl function with import wizard data.

and to clear enough, when I use foreign afl function with my import wizard csv files, found my mapping field prices not matched with my import wizard csv files data values,

according to my indicator parameters I choice from field prices drop down list open and not return data of open which i mapped that field price (OPEN) with the 3rd columns which called (NET (value)FLOW) returned other column value that my codes and snapshoot cleared my issues. thanks



																		// 	Indicator Defination
												//===================================================================================================
												//===================================================================================================

												// Indicator : Super Volume && Turnover Indicator.
												// Author    : Ahmad Elsayed Ibrahim
												// Options   : Get Volumes, Cum Volumes, Adjusment Volume, Cum adjusment Volume,  Turnover, Cum Turnover, Adjusment Turnover, Cum adjusment Turnover.
												// Ploting   : Volumes, Cum Volumes, Adjusment Volume, Cum adjusment Volume,  Turnover, Cum Turnover, Adjusment Turnover, Cum adjusment Turnover..

												//===================================================================================================
												//===================================================================================================


		// Build Func to Set EndFieldPrice ::
//===================================================
//===================================================
function SetEndingPrice( endingPriceParameter, todayIndex )
{
    /*
    parameters:
    -----------
    endingPriceParameter : list of strings
    	input parameter that the user chooses from UI input parameters windows

    todayIndex : int
    	the calculated index of today


    returns: pricefield(array)
    	the value of the price the user chose for today
    */
    endPriceField = 0;

    if( endingPriceParameter == 0 )
        endPriceField = C[todayIndex];

    else
        endPriceField = OpenInt[todayIndex];

    return( endPriceField );

}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

// Ending Price input paramter:  
rr         = ParamStr  ( "Super(Volumes && Turnover) Param","--------------------------------------------------------");  
FromTo_acti = ParamToggle( "From To Activation", "off|on", 0 );
StartDateTime    = ParamDate("Start Date(YY/mm/dd)","2024-09-18",0);
EndDateTime      = ParamDate("End   Date(YY/mm/dd)","2024-09-18 ",0);
endingPriceParam = ParamToggle( "Ending Price", "Last|VWAP", 0 );
basedon          = ParamList( "Use Case", "Standard|Flow|MarketBreadth", 0 );
basedon1         = ParamList( "MarketBreadth Case(used with MB only)", "L_Count|S_Count|(L_Count - S_Count)", 0 );
//-------------------------------

TickerExtopen     = Null;
TickerExthigh     = Null;
TickerExtlow      = Null;
TickerExtclose    = Null;
TickerExtopenInt  = Null;
TickerExtvolume   = Null;

Ticker1Extopen    = Null;
Ticker1Exthigh    = Null;
Ticker1Extlow     = Null;
Ticker1Extclose   = Null;
Ticker1ExtopenInt = Null;
Ticker1Extvolume  = Null;


Ticker2Extopener      = Null;
Ticker2Exthigher      = Null;
Ticker2Extlower       = Null;
Ticker2Extcloser      = Null;
Ticker2ExtopenInter   = Null;
Ticker2Extvolumer     = Null;

switch( basedon )
{
	case "Standard":
		TickerExtopen    = o;
		TickerExthigh    = h;
		TickerExtlow     = l;
		TickerExtclose   = c;
		TickerExtopenInt = OpenInt;    
		TickerExtvolume  = v;
		break;
	case "Flow":
		//TickerExtopen    = Foreign    ( Name()+" FLOW" , "O" );  
		//TickerExthigh    = Foreign    ( Name()+" FLOW" , "H" );
		//TickerExtlow     = Foreign    ( Name()+" FLOW" , "L" );
		//TickerExtclose   = Foreign    ( Name()+" FLOW" , "C" );
		//TickerExtopenInt = Foreign    ( Name()+" FLOW" , "I" );
		//TickerExtvolume  = Foreign    ( Name()+" FLOW" , "V" );
		
		SetForeign( Name() + " FLOW" );
		TickerExtopen    = O;
		TickerExthigh    = H;
		TickerExtlow     = L;
		TickerExtclose   = C;
		TickerExtopenInt = OpenInt; 
		TickerExtvolume  = V;
		RestorePriceArrays();
		break;
	case "MarketBreadth":
		TickerExtopen     = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "O" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "O" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "O" ) -Foreign ( Name()+"_S_Count" , "O" )), O  ) ) );
		TickerExthigh     = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "H" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "H" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "H" ) -Foreign ( Name()+"_S_Count" , "H" )), H  ) ) );
		TickerExtlow      = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "L" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "L" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "L" ) -Foreign ( Name()+"_S_Count" , "L" )), L  ) ) );
		TickerExtclose    = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "C" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "C" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "C" ) -Foreign ( Name()+"_S_Count" , "C" )), C  ) ) );
		TickerExtvolume   = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "V" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "V" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "V" ) -Foreign ( Name()+"_S_Count" , "V" )), V  ) ) );
		TickerExtopenInt  = IIf( basedon1 =="L_Count", Foreign ( Name()+"_L_Count" , "I" ), IIf( basedon1 =="S_Count", Foreign ( Name()+"_S_Count" , "I" ), IIf( basedon1 =="(L_Count - S_Count)", (Foreign ( Name()+"_L_Count" , "I" ) -Foreign ( Name()+"_S_Count" , "I" )), OpenInt  ) ) );


		
		Ticker2Extopener      = Foreign    ( Name()+"_L_Count" , "O" )  - Foreign    ( Name()+"_S_Count" , "O" );
		Ticker2Exthigher      = Foreign    ( Name()+"_L_Count" , "H" )  - Foreign    ( Name()+"_S_Count" , "H" );
		Ticker2Extlower       = Foreign    ( Name()+"_L_Count" , "L" )  - Foreign    ( Name()+"_S_Count" , "L" );
		Ticker2Extcloser      = Foreign    ( Name()+"_L_Count" , "C" )  - Foreign    ( Name()+"_S_Count" , "C" );
		Ticker2ExtopenInter   = Foreign    ( Name()+"_L_Count" , "I" )  - Foreign    ( Name()+"_S_Count" , "I" );
		Ticker2Extvolumer     = Foreign    ( Name()+"_L_Count" , "V" )  - Foreign    ( Name()+"_S_Count" , "V" );
		
		break;


}
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
// Used To control DT of AMIbroker Exploration Interface:
//-----------------------------------------------





fbr  = Status( "firstbarinrange" ); 
lbr  = Status( "lastbarinrange" );
bi   = BarIndex();

// Number of Bars over DT Period ::
NTD= ValueWhen( lbr, bi ) - ValueWhen( fbr, bi ); 

// get summution Volume over custom period DT
DT_open    = Sum(TickerExtopen    , NTD+1);
DT_High    = Sum(TickerExthigh    , NTD+1);
DT_low     = Sum(TickerExtlow     , NTD+1);
DT_close   = Sum(TickerExtclose   , NTD+1);
DT_volume  = Sum(TickerExtvolume  , NTD+1);
DT_openInt = Sum(TickerExtopenInt , NTD+1);

DT_openclr     =  IIf( DT_open    > 0, colorGreen, colorRed );
DT_Highclr     =  IIf( DT_High    > 0, colorGreen, colorRed );
DT_lowclr      =  IIf( DT_low     > 0, colorGreen, colorRed );
DT_closeclr    =  IIf( DT_close   > 0, colorGreen, colorRed );
DT_openIntclr  =  IIf( DT_openInt > 0, colorGreen, colorRed );
DT_volumeclr   =  IIf( DT_volume  > 0, colorGreen, colorRed );



if (FromTo_acti)
{

AddColumn(DT_open    , "From-To dates (DT_open)"   , format = 1.2, textColor = colorBlack  ,bkgndColor = DT_openclr   );
AddColumn(DT_High    , "From-To dates (DT_High)"   , format = 1.2, textColor = colorBlack  ,bkgndColor = DT_Highclr   );
AddColumn(DT_low     , "From-To dates (DT_low)"    , format = 1.2, textColor = colorBlack  ,bkgndColor = DT_lowclr    );
AddColumn(DT_close   , "From-To dates (DT_close)"  , format = 1.2, textColor = colorBlack  ,bkgndColor = DT_closeclr  );
AddColumn(DT_openInt , "From-To dates (DT_openInt)", format = 1.2, textColor = colorBlack  ,bkgndColor = DT_openIntclr);
AddColumn(DT_volume  , "From-To dates (DT_volume)" , format = 1.2, textColor = colorBlack  ,bkgndColor = DT_volumeclr );


}

//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
dn = DateNum();
inDatesRange = True;
newday = iif( dn == StartDateTime, 1, 0 );
inDatesRange = dn >= StartDateTime AND dn <= EndDateTime;
openers=0;
for( i= 0; i < BarCount; i++ ) 
{ 
    // only want to reset our values at the start of a new day
    if (newday[i]==True)
    {
        openers=0;

    }
	openers = TickerExtopen[i];



}



//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------

Plot_type = ParamList( "Ploting type", "Open|High|Low|Close|OpenInt|Volume|CUM Volumes|Adjust Volumes|CUM Adjust Volumes|Turnovers|CUM Turnovers|Adjust Turnovers|CUM Adjust Turnovers", 0 ); 
endPricestick = IIf( endingPriceParam ==0 , TickerExtclose, TickerExtopenInt );
// get Coloring case ::

Currclose = endPricestick;
Curropen  = TickerExtopen;

Prevclose    = Ref( endPricestick    , -1 );
Prevopen     = Ref( TickerExtopen    , -1 );
Prevhigh     = Ref( TickerExthigh    , -1 );
Prevlow      = Ref( TickerExtlow     , -1 );
Prevvolume   = Ref( TickerExtvolume  , -1 );
PrevopenInt  = Ref( TickerExtopenInt , -1 );

preclr    =  IIf( Prevclose > Prevopen, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));

finalclr  = IIf( Currclose > Curropen, ParamColor("Up Color", colorGreen ), IIf( Currclose < Curropen, ParamColor("Down Color", colorRed ), preclr ) );

openpreclr       = IIf( Prevopen    > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
openfinalclr     = IIf( TickerExtopen    > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExtopen < 0, ParamColor("Down Color", colorRed ), openpreclr ) );

highpreclr       = IIf( Prevhigh    > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
highfinalclr     = IIf( TickerExthigh    > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExthigh < 0, ParamColor("Down Color", colorRed ), highpreclr ) );

lowpreclr        = IIf( Prevlow     > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
lowfinalclr      = IIf( TickerExtlow     > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExtlow < 0, ParamColor("Down Color", colorRed ), lowpreclr ) );

closepreclr      = IIf( Prevclose   > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
closefinalclr    = IIf( TickerExtclose   > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExtclose < 0, ParamColor("Down Color", colorRed ), closepreclr ) );

openIntpreclr    = IIf( PrevopenInt > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
openIntfinalclr  = IIf( TickerExtopenInt > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExtopenInt < 0, ParamColor("Down Color", colorRed ), openIntpreclr ) );

volumepreclr    = IIf( Prevvolume > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
volumefinalclr  = IIf( TickerExtvolume > 0, ParamColor("Up Color", colorGreen ), IIf( TickerExtvolume < 0, ParamColor("Down Color", colorRed ), volumepreclr ) );


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Opens_val = IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen ,  null), TickerExtopen)  ;  
if(Plot_type == "Open")
	Plot( Opens_val, "Open", IIf( basedon =="Standard" ,finalclr, openfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	//Plot( iif(inDatesRange, Opens_val ,  null), "openers", IIf( basedon =="Standard" ,finalclr, openfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Highs_val = IIf( FromTo_acti ,iif(inDatesRange, TickerExthigh ,  null), TickerExthigh)  ;  
if(Plot_type == "High")
	Plot( Highs_val, "High", IIf( basedon =="Standard" ,finalclr, highfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Lows_val =  IIf( FromTo_acti ,iif(inDatesRange, TickerExtlow ,  null), TickerExtlow)  ;     
if(Plot_type == "Low")
	Plot( Lows_val, "Low", IIf( basedon =="Standard" ,finalclr, lowfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Closes_val = IIf( FromTo_acti ,iif(inDatesRange, TickerExtclose ,  null), TickerExtclose)  ;  
if(Plot_type == "Close")
	Plot( Closes_val, "Close", IIf( basedon =="Standard" ,finalclr, closefinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
OpenInts_val = IIf( FromTo_acti ,iif(inDatesRange, TickerExtopenInt ,  null), TickerExtopenInt)  ;     
if(Plot_type == "OpenInt")
	Plot( OpenInts_val, "OpenInt", IIf( basedon =="Standard" ,finalclr, openIntfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------


Volumes_val = IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume ,  null), TickerExtvolume)  ;    
if(Plot_type == "Volume")
	Plot( Volumes_val, "Volume", IIf( basedon =="Standard" ,finalclr, volumefinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
	
//-----------------------------------------------------------------------------
// CUM Volumes values
CUMVolumes =  IIf( FromTo_acti ,iif(inDatesRange, Cum(TickerExtvolume) ,  null), Cum(TickerExtvolume))  ;
PrevCUMVolumes      = Ref( CUMVolumes    , -1 );
CUMVolumespreclr    = IIf( PrevCUMVolumes > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
CUMVolumesfinalclr  = IIf( CUMVolumes > 0, ParamColor("Up Color", colorGreen ), IIf( CUMVolumes < 0, ParamColor("Down Color", colorRed ), CUMVolumespreclr ) );


if(Plot_type == "CUM Volumes")
	Plot( CUMVolumes, "CUM Volumes", IIf( basedon =="Standard" ,finalclr, CUMVolumesfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//-----------------------------------------------------------------------------
// Adj Volumes values

Up_Volumes_val     =  1*(IIf( FromTo_acti ,iif(inDatesRange, Cum(TickerExtvolume) ,  null), Cum(TickerExtvolume))  );
Dowm_Volumes_val   = -1*(IIf( FromTo_acti ,iif(inDatesRange, Cum(TickerExtvolume) ,  null), Cum(TickerExtvolume))  );




adjust_Volumes_val = IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) > IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen), Up_Volumes_val, IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) < IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen), Dowm_Volumes_val, 0 ) );
Prevadjust_Volumes_val      = Ref( adjust_Volumes_val    , -1 );
adjust_Volumes_valpreclr    = IIf( Prevadjust_Volumes_val > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
adjust_Volumes_valfinalclr  = IIf( adjust_Volumes_val > 0, ParamColor("Up Color", colorGreen ), IIf( adjust_Volumes_val < 0, ParamColor("Down Color", colorRed ), adjust_Volumes_valpreclr ) );

if(Plot_type == "Adjust Volumes")
	Plot( adjust_Volumes_val, "Adjust Volumes", IIf( basedon =="Standard" ,finalclr, adjust_Volumes_valfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//-----------------------------------------------------------------------------
// CUM Adj Volumes values
Up_adjVolumes_val     =  1*(IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume));
Dowm_adjVolumes_val   = -1*(IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume)); 




adjust_Volumes_val = IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) > IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen), Up_adjVolumes_val, IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) < IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen), Dowm_adjVolumes_val, 0 ) );
Cum_adjust_Volumes_val = IIf( FromTo_acti ,iif(inDatesRange, Cum(adjust_Volumes_val),  null), Cum(adjust_Volumes_val)); 

PrevCum_adjust_Volumes_val      = Ref( Cum_adjust_Volumes_val    , -1 );
Cum_adjust_Volumes_valpreclr    = IIf( PrevCum_adjust_Volumes_val > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
Cum_adjust_Volumes_valfinalclr  = IIf( Cum_adjust_Volumes_val > 0, ParamColor("Up Color", colorGreen ), IIf( Cum_adjust_Volumes_val < 0, ParamColor("Down Color", colorRed ), Cum_adjust_Volumes_valpreclr ) );


if(Plot_type == "CUM Adjust Volumes")
	Plot( Cum_adjust_Volumes_val, "CUM Adjust Volumes", IIf( basedon =="Standard" ,finalclr, Cum_adjust_Volumes_valfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//===================================================================================================================================================================================================================
//===================================================================================================================================================================================================================
//===================================================================================================================================================================================================================
//===================================================================================================================================================================================================================
//===================================================================================================================================================================================================================
//===================================================================================================================================================================================================================
																		// Turnover Data Preprocessing ::


// STD Volumes values
Turnovers_val = (IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume)) * (IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ); 

 
PrevTurnovers_val      = Ref( Turnovers_val    , -1 );
Turnovers_valpreclr    = IIf( PrevTurnovers_val > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
Turnovers_valfinalclr  = IIf( Turnovers_val > 0, ParamColor("Up Color", colorGreen ), IIf( Turnovers_val < 0, ParamColor("Down Color", colorRed ), Turnovers_valpreclr ) );

 
if(Plot_type == "Turnovers")
	Plot( Turnovers_val, "Turnovers", IIf( basedon =="Standard" ,finalclr, Turnovers_valfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//-----------------------------------------------------------------------------

// CUM Turnovers values
CUMTurnovers = Cum((IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume) )*(IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ));

PrevCUMTurnovers      = Ref( CUMTurnovers    , -1 );
CUMTurnoverspreclr    = IIf( PrevCUMTurnovers > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
CUMTurnoversfinalclr  = IIf( CUMTurnovers > 0, ParamColor("Up Color", colorGreen ), IIf( CUMTurnovers < 0, ParamColor("Down Color", colorRed ), CUMTurnoverspreclr ) );


if(Plot_type == "CUM Turnovers")
	Plot( CUMTurnovers, "CUM Turnovers", IIf( basedon =="Standard" ,finalclr, CUMTurnoversfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );	
//-----------------------------------------------------------------------------
// Adj Turnover values

Up_Turnover_val     =  1*((IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume) )*(IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ));
Dowm_Turnover_val   = -1*((IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume) )*(IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ));


adjust_Turnover_val = IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick)  > IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen) , Up_Turnover_val, IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick)  < IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen) , Dowm_Turnover_val, 0 ) );

Prevadjust_Turnover_val      = Ref( adjust_Turnover_val    , -1 );
adjust_Turnover_valpreclr    = IIf( Prevadjust_Turnover_val > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
adjust_Turnover_valfinalclr  = IIf( adjust_Turnover_val > 0, ParamColor("Up Color", colorGreen ), IIf( adjust_Turnover_val < 0, ParamColor("Down Color", colorRed ), adjust_Turnover_valpreclr ) );


if(Plot_type == "Adjust Turnovers")
	Plot( adjust_Turnover_val, "Adjust Turnovers", IIf( basedon =="Standard" ,finalclr, adjust_Turnover_valfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );
//-----------------------------------------------------------------------------
// CUM Adj Turnover values
Up_Turnover_val         =  1*((IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume) )*(IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ));
Dowm_Turnover_val       = -1*((IIf( FromTo_acti ,iif(inDatesRange, TickerExtvolume,  null), TickerExtvolume) )*(IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick) ));




adjust_Turnover_val     = IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick)  > IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen) , Up_Turnover_val, IIf( IIf( FromTo_acti ,iif(inDatesRange, endPricestick,  null), endPricestick)  < IIf( FromTo_acti ,iif(inDatesRange, TickerExtopen,  null), TickerExtopen) , Dowm_Turnover_val, 0 ) );
Cum_adjust_Turnover_val = IIf( FromTo_acti ,iif(inDatesRange, Cum(adjust_Turnover_val),  null), Cum(adjust_Turnover_val)) ;



PrevCum_adjust_Turnover_val      = Ref( Cum_adjust_Turnover_val    , -1 );
Cum_adjust_Turnover_valpreclr    = IIf( PrevCum_adjust_Turnover_val > 0, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ));
Cum_adjust_Turnover_valfinalclr  = IIf( Cum_adjust_Turnover_val > 0, ParamColor("Up Color", colorGreen ), IIf( Cum_adjust_Turnover_val < 0, ParamColor("Down Color", colorRed ), Cum_adjust_Turnover_valpreclr ) );


if(Plot_type == "CUM Adjust Turnovers")
	Plot( Cum_adjust_Turnover_val, " CUM Adjust Turnovers", IIf( basedon =="Standard" ,finalclr, Cum_adjust_Turnover_valfinalclr), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );

//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
//==========================================================================================================================================================
CC         = ParamStr  ( "MA Param","--------------------------------------------------------");
Pp         = ParamList ( "MA Price field", "Open|High|Low|Close|OpenInt|Volume|CUM Volumes|Adjust Volumes|CUM Adjust Volumes|Turnovers|CUM Turnovers|Adjust Turnovers|CUM Adjust Turnovers" , 3);    
MAPeriod   = Param     ( "MA Period"     , 15, 2, 300, 1, 10 );
MAMethod   = ParamList ( "MA MAMethod"   , "Simple|Exponential|Weighted|Hull" , 0);
MAStyle    = ParamStyle( "MA Style"      , styleNoDraw );
MAUpColor  = ParamColor( "MA UpColor"    , colorGreen);
MADwnColor = ParamColor( "MA DownColor"  , colorRed);
//--------------------------------------
CC1         = ParamStr  ( "MA1 Param","--------------------------------------------------------");
Pp1         = ParamList ( "MA1 Price field", "Open|High|Low|Close|OpenInt|Volume|CUM Volumes|Adjust Volumes|CUM Adjust Volumes|Turnovers|CUM Turnovers|Adjust Turnovers|CUM Adjust Turnovers" , 3);    
MA1Period   = Param     ( "MA1 Period"     , 15, 2, 300, 1, 10 );
MA1Method   = ParamList ( "MA1 MAMethod"   , "Simple|Exponential|Weighted|Hull" , 0);
MA1Style    = ParamStyle( "MA1 Style"      , styleNoDraw );
MA1UpColor  = ParamColor( "MA1 UpColor"    , colorGreen);
MA1DwnColor = ParamColor( "MA1 DownColor"  , colorRed);
//--------------------------------------
CC2         = ParamStr  ( "MA2 Param","--------------------------------------------------------");
Pp2         = ParamList ( "MA2 Price field", "Open|High|Low|Close|OpenInt|Volume|CUM Volumes|Adjust Volumes|CUM Adjust Volumes|Turnovers|CUM Turnovers|Adjust Turnovers|CUM Adjust Turnovers" , 3);    
MA2Period   = Param     ( "MA2 Period"     , 15, 2, 300, 1, 10 );
MA2Method   = ParamList ( "MA2 MAMethod"   , "Simple|Exponential|Weighted|Hull" , 0);
MA2Style    = ParamStyle( "MA2 Style"      , styleNoDraw );
MA2UpColor  = ParamColor( "MA2 UpColor"    , colorGreen);
MA2DwnColor = ParamColor( "MA2 DownColor"  , colorRed);
//--------------------------------------
CC3         = ParamStr  ( "MA3 Param","--------------------------------------------------------");
Pp3         = ParamList ( "MA3 Price field", "Open|High|Low|Close|OpenInt|Volume|CUM Volumes|Adjust Volumes|CUM Adjust Volumes|Turnovers|CUM Turnovers|Adjust Turnovers|CUM Adjust Turnovers" , 3);    
MA3Period   = Param     ( "MA3 Period"     , 15, 2, 300, 1, 10 );
MA3Method   = ParamList ( "MA3 MAMethod"   , "Simple|Exponential|Weighted|Hull" , 0);
MA3Style    = ParamStyle( "MA3 Style"      , styleNoDraw );
MA3UpColor  = ParamColor( "MA3 UpColor"    , colorGreen);
MA3DwnColor = ParamColor( "MA3 DownColor"  , colorRed);
//--------------------------------------
//--------------------------------------  



MAval =0;
switch( Pp )
{
	case "Open":
		MAval = TickerExtopen; 
		break;

	case "High":
		MAval = TickerExthigh;
		break;

	case "Low":
		MAval = TickerExtlow;
		break;

	case "Close":
		MAval = TickerExtclose;
		break;
		
	case "OpenInt":
		MAval = TickerExtopenInt;
		break;
		
	case "Volume":
		MAval = TickerExtvolume;
		break;

	case "CUM Volumes":
		MAval = CUMVolumes;
		break;

	case "Adjust Volumes":
		MAval = adjust_Volumes_val;
		break;

	case "CUM Adjust Volumes":
		MAval = Cum_adjust_Volumes_val;
		break;

	case "Turnovers":
		MAval = Turnovers_val;
		break;

	case "CUM Turnovers":
		MAval = CUMTurnovers;
		break;

	case "Adjust Turnovers":
		MAval = adjust_Turnover_val;
		break;

	case "CUM Adjust Turnovers":
		MAval = Cum_adjust_Turnover_val;
		break;



}
//--------------------------------------

MOV = 0;
switch( MAMethod )
{
	case "Simple":
		MOV = MA( MAval, MAPeriod );
		break;

	case "Exponential":
		MOV = EMA( MAval, MAPeriod );
		break;

	case "Weighted":
		MOV = WMA( MAval, MAPeriod );
		break;
		
	case "Hull":
		MOV = HMA( MAval, MAPeriod );
		break;
}
//-------------------------------------------
MOVtrend = 0;


for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( MOV[i] > MOV[i - 1] )
			MOVtrend[i] = 1;
		else
		{
			if( MOV[i] < MOV[i - 1] )
				MOVtrend[i] = -1;
			else
				MOVtrend[i] = MOVtrend[i - 1];
		}
	}
	else
		MOVtrend[i] = 0;
}

//-------------------------------------------
//-------------------------------------------
upMOV = MOVtrend > 0;
downMOV = MOVtrend < 0;
MAColor  = IIf( upMOV, MAUpColor, IIf( downMOV, MADwnColor, MAUpColor ) );
// Ploting MA 6:
//==============
Plot( MOV, "MOV" + "(" + MAPeriod + ")" , MAColor ,  MAStyle , Null, Null, 0, 0, 2 );
//-------------------------------------------
//-------------------------------------------
//-------------------------------------------
MA1val =0;
switch( Pp1 )
{
	case "Open":
		MA1val = TickerExtopen;
		break;

	case "High":
		MA1val = TickerExthigh;
		break;

	case "Low":
		MA1val = TickerExtlow;
		break;

	case "Close":
		MA1val = TickerExtclose;
		break;
		
		
	case "OpenInt":
		MA1val = TickerExtopenInt;
		break;

	case "Volume":
		MA1val = TickerExtvolume;
		break;

	case "CUM Volumes":
		MA1val = CUMVolumes;
		break;

	case "Adjust Volumes":
		MA1val = adjust_Volumes_val;
		break;

	case "CUM Adjust Volumes":
		MA1val = Cum_adjust_Volumes_val;
		break;

	case "Turnovers":
		MA1val = Turnovers_val;
		break;

	case "CUM Turnovers":
		MA1val = CUMTurnovers;
		break;

	case "Adjust Turnovers":
		MA1val = adjust_Turnover_val;
		break;

	case "CUM Adjust Turnovers":
		MA1val = Cum_adjust_Turnover_val;
		break;


}
//--------------------------------------
MOV1 = 0;
switch( MA1Method )
{
	case "Simple":
		MOV1 = MA( MA1val, MA1Period );
		break;

	case "Exponential":
		MOV1 = EMA( MA1val, MA1Period );
		break;

	case "Weighted":
		MOV1 = WMA( MA1val, MA1Period );
		break;
		
	case "Hull":
		MOV1 = HMA( MA1val, MA1Period );
		break;
}
//-------------------------------------------
MOV1trend = 0;


for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( MOV1[i] > MOV1[i - 1] )
			MOV1trend[i] = 1;
		else
		{
			if( MOV1[i] < MOV1[i - 1] )
				MOV1trend[i] = -1;
			else
				MOV1trend[i] = MOV1trend[i - 1];
		}
	}
	else
		MOV1trend[i] = 0;
}

//-------------------------------------------
//-------------------------------------------
upMOV1 = MOV1trend > 0;
downMOV1 = MOV1trend < 0;
MA1Color  = IIf( upMOV1, MA1UpColor, IIf( downMOV1, MA1DwnColor, MA1UpColor ) );
// Ploting MA 6:
//==============
Plot( MOV1, "MOV1" + "(" + MA1Period + ")" , MA1Color ,  MA1Style , Null, Null, 0, 0, 2 );
//-------------------------------------------
//-------------------------------------------
//-------------------------------------------
MA2val =0;
switch( Pp2 )
{
	case "Open":
		MA2val = TickerExtopen;
		break;

	case "High":
		MA2val = TickerExthigh;
		break;

	case "Low":
		MA2val = TickerExtlow;
		break;

	case "Close":
		MA2val = TickerExtclose;
		break;
		
	case "OpenInt":
		MA2val = TickerExtopenInt;
		break;

	case "Volume":
		MA2val = TickerExtvolume;
		break;

	case "CUM Volumes":
		MA2val = CUMVolumes;
		break;

	case "Adjust Volumes":
		MA2val = adjust_Volumes_val;
		break;

	case "CUM Adjust Volumes":
		MA2val = Cum_adjust_Volumes_val;
		break;

	case "Turnovers":
		MA2val = Turnovers_val;
		break;

	case "CUM Turnovers":
		MA2val = CUMTurnovers;
		break;

	case "Adjust Turnovers":
		MA2val = adjust_Turnover_val;
		break;

	case "CUM Adjust Turnovers":
		MA2val = Cum_adjust_Turnover_val;
		break;

}

//--------------------------------------
MOV2 = 0;
switch( MA2Method )
{
	case "Simple":
		MOV2 = MA( MA2val, MA2Period );
		break;

	case "Exponential":
		MOV2 = EMA( MA2val, MA2Period );
		break;

	case "Weighted":
		MOV2 = WMA( MA2val, MA2Period );
		break;
		
	case "Hull":
		MOV2 = HMA( MA2val, MA2Period );
		break;
}
//-------------------------------------------
MOV2trend = 0;


for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( MOV2[i] > MOV2[i - 1] )
			MOV2trend[i] = 1;
		else
		{
			if( MOV2[i] < MOV2[i - 1] )
				MOV2trend[i] = -1;
			else
				MOV2trend[i] = MOV2trend[i - 1];
		}
	}
	else
		MOV2trend[i] = 0;
}

//-------------------------------------------
//-------------------------------------------
upMOV2 = MOV2trend > 0;
downMOV2 = MOV2trend < 0;
MA2Color  = IIf( upMOV2, MA2UpColor, IIf( downMOV2, MA2DwnColor, MA2UpColor ) );
// Ploting MA 6:
//==============
Plot( MOV2, "MOV2" + "(" + MA2Period + ")" , MA2Color ,  MA2Style , Null, Null, 0, 0, 2 );
//--------------------------------------
//-------------------------------------------
//-------------------------------------------
MA3val =0;
switch( Pp3 )
{
	case "Open":
		MA3val = TickerExtopen;
		break;

	case "High":
		MA3val = TickerExthigh;
		break;

	case "Low":
		MA3val = TickerExtlow;
		break;

	case "Close":
		MA3val = TickerExtclose;
		break;
		
		
	case "OpenInt":
		MA3val = TickerExtopenInt;
		break;

	case "Volume":
		MA3val = TickerExtvolume;
		break;

	case "CUM Volumes":
		MA3val = CUMVolumes;
		break;

	case "Adjust Volumes":
		MA3val = adjust_Volumes_val;
		break;

	case "CUM Adjust Volumes":
		MA3val = Cum_adjust_Volumes_val;
		break;

	case "Turnovers":
		MA3val = Turnovers_val;
		break;

	case "CUM Turnovers":
		MA3val = CUMTurnovers;
		break;

	case "Adjust Turnovers":
		MA3val = adjust_Turnover_val;
		break;

	case "CUM Adjust Turnovers":
		MA3val = Cum_adjust_Turnover_val;
		break;

}



MOV3 = 0;
switch( MA3Method )
{
	case "Simple":
		MOV3 = MA( MA3val, MA3Period );
		break;

	case "Exponential":
		MOV3 = EMA( MA3val, MA3Period );
		break;

	case "Weighted":
		MOV3 = WMA( MA3val, MA3Period );
		break;
		
	case "Hull":
		MOV3 = HMA( MA3val, MA3Period );
		break;
}
//-------------------------------------------
MOV3trend = 0;


for( i = 1 ; i < BarCount; i++ )
{
	if( i < BarCount )
	{
		if( MOV3[i] > MOV3[i - 1] )
			MOV3trend[i] = 1;
		else
		{
			if( MOV3[i] < MOV3[i - 1] )
				MOV3trend[i] = -1;
			else
				MOV3trend[i] = MOV3trend[i - 1];
		}
	}
	else
		MOV3trend[i] = 0;
}

//-------------------------------------------
//-------------------------------------------
upMOV3 = MOV3trend > 0;
downMOV3 = MOV3trend < 0;
MA3Color  = IIf( upMOV3, MA3UpColor, IIf( downMOV3, MA3DwnColor, MA3UpColor ) );
// Ploting MA 6:
//==============
Plot( MOV3, "MOV3" + "(" + MA3Period + ")" , MA3Color ,  MA3Style , Null, Null, 0, 0, 2 );
//-------------------------------------------
//-------------------------------------------
op  = ParamStr( "options Parameters","--------------------------------------------------------");
option1sel  = ParamList ( "selection"      , "MA|MA1|M2|M3" , 0);        
rule        = ParamList ( "Rules"          , "above|blew"   , 0);	
option2sel  = ParamList ( "selection1"     , "MA|MA1|M2|M3" , 1);      
MAsUpColor  = ParamColor( "MAs above Color" , colorGreen);
MAsDwnColor = ParamColor( "MAs blew Color"  , colorRed);
MAsStyle    = ParamStyle( "MAs Style"       , styleNoDraw);












selDataChoice1 = 0;

switch( option1sel )
{
	

	case "MA":
		selDataChoice1 = MOV;
		break;

	case "MA1":
		selDataChoice1 = MOV1;
		break;

	case "MA2":
		selDataChoice1 = MOV2;
		break;

	case "MA3":
		selDataChoice1 = MOV3;
		break;

}

//--------------------
selDataChoice2 = 0;
switch( option2sel )
{
	

	case "MA":
		selDataChoice2 = MOV;
		break;

	case "MA1":
		selDataChoice2 = MOV1;
		break;

	case "MA2":
		selDataChoice2 = MOV2;
		break;

	case "MA3":
		selDataChoice2 = MOV3;
		break;


}
//------------------------------------
//------------------------------------
//------------------------------------
// Up and Down colors 

upMA   = selDataChoice1 > selDataChoice2;;
downMA = selDataChoice1 < selDataChoice2;


MAsColor  = IIf( upMA AND rule == "above", MAsUpColor,MAsDwnColor );


// Ploting MA 6:
//--------------
Plot( selDataChoice1, "MA", MAsColor, MAsStyle  );

								
Filter = C;
Filter = lbr;







Please write in English, because what you posted is in some weird language. Use shorter sentences and proper punctuation. Never ending single sentence can't be understood (at least by me). Maybe some bullet points of what you are after?