OverBought - OverSold explorer indicator "newbie" question

Discussion in 'AmiBroker' started by xel, Jul 20, 2012.

  1. xel

    xel Member

    Joined:
    Oct 10, 2011
    Messages:
    30
    Likes Received:
    2
    Trophy Points:
    8
    Hi, For an exploration indicator for an oscillator, let's talk about RSI, I want to do something like this:

    Code:
    RSIOb   =   70
    RSIOs   =   30
    
            [COLOR="Red"]RSIUt		=	RSI(14)		>	Ref(RSI(14),-1);
    	RSIDt		=	RSI(14)		< 	Ref(RSI(14),-1);
    	RSIBuy		=	RSI		<	RSIOs AND ARSIUt;
    	RSISell		=	RSI		>	RSIOb AND ARSIDt;[/COLOR]
    
    RSI_Status		=	WriteIf(RSIBuy,"-=BUY=-",
    				WriteIf(RSI(14) > RSIOs,"OverSold",
    				WriteIf(RSIUt,"Improving",
    				WriteIf(RSIDt,"Declining",
    				WriteIf(RSI < RSIOb,"OverBought",
    				WriteIf(RSISell,"-=SELL=-",""))))));
    RSI_Color		=	IIf(RSIBuy,Color_buy,
    				IIf(RSI>ARSIOs,Color_bull,
    				IIf(RSIUt,Color_bull1,
    				IIf(RSIDt,Color_bear1,
    				IIf(RSI<ARSIOb,Color_bear,
    				IIf(RSISell,Color_sell,Color_null))))));
    
    Filter = 1;
    
    AddColumn		(RSI_Status,"RSI (14)",1,ColorWhite,RSI_Color);
    
    
    
    The result I want to obtain on the explorer indicator is the following:
    1) BUY: When the RSI(14) are below the RSIOs level AND the trend of the indicator are upwards regarding it's last position.

    2) Sell: When the RSI(14) are above the RSIOb level AND the trend of the indicator are downwards regarding it's last postion.

    3) Trend: When the indicator is between the OverBought and OverSold levels, only reads the trend lecture regarding it's last position.

    ... What is wrong with the logic I am applying as marded on the Red Code ? I am missing something ?
     
  2. KelvinHand

    KelvinHand Well-Known Member

    Joined:
    Jun 4, 2008
    Messages:
    918
    Likes Received:
    1,162
    Trophy Points:
    93
    Location:
    Banned Forever
    Give so much typo errors and not including the colors in the code. How you expect people to help you ?

    Base on your logic:

    1. RSIBuy : RSI(14) < RSIOs AND RSIUt;
    Buy when RSI below 30 and the current RSI is slope up but still did not break above 30

    2. RSISell : RSI(14) > RSIOb AND RSIDt;
    Sell when RSI above 70 and the current RSI is slope down but still did break below 70

    3. WriteIf(RSI(14) > RSIOs,"OverSold",
    RSI > 30, how can be oversold ?

    4. WriteIf(RSI(14) < RSIOb,"OverBought",
    RSI < 70, how can be OverBought ?

    5. If above logic is wrong. you are not able to do trend between 30 to 70


    The following scripts rectified the errors but not rectified the logic.
    Code:
    Color_buy = colorGreen;
    Color_bull = colorLime;
    Color_bull1 = colorAqua;
    Color_null = colorGrey40;
    Color_bear = colorRed;
    Color_bear1 = colorPink;
    Color_sell = colorGold; 
    
    
    RSIOb   =   70;
    RSIOs   =   30;
    
      RSIUt		=	RSI(14)		>	Ref(RSI(14),-1);
    	RSIDt		=	RSI(14)		< 	Ref(RSI(14),-1);
    	RSIBuy		=	RSI(14)		<	RSIOs AND RSIUt;
    	RSISell		=	RSI(14)		>	RSIOb AND RSIDt;
    
    RSI_Status		=	WriteIf(RSIBuy,"-=BUY=-",
    				WriteIf(RSI(14) > RSIOs,"OverSold",
    				WriteIf(RSIUt,"Improving",
    				WriteIf(RSIDt,"Declining",
    				WriteIf(RSI(14) < RSIOb,"OverBought",
    				WriteIf(RSISell,"-=SELL=-",""))))));
    RSI_Color		=	IIf(RSIBuy,Color_buy,
    				IIf(RSI(14)>RSIOs,Color_bull,
    				IIf(RSIUt,Color_bull1,
    				IIf(RSIDt,Color_bear1,
    				IIf(RSI(14)<RSIOb,Color_bear,
    				IIf(RSISell,Color_sell,Color_null))))));
    
    Filter = 1;
    
    AddTextColumn		(RSI_Status,"RSI (14)",1,colorWhite,RSI_Color);
    
     
    Last edited: Aug 30, 2012

Share This Page