Thema: Neues Projekt
Einzelnen Beitrag anzeigen
  #9 (permalink)  
Alt 10.01.22
Sirocool Sirocool ist offline
Mitglied
 
Registriert seit: Feb 2014
Ort: Berlin
Beiträge: 42
Sirocool befindet sich auf einem aufstrebenden Ast
Standard Update RSI Arrows_Signale

Code:
//+------------------------------------------------------------------+
//|                 SHARK_RSI_CLASSIC_V.22 - 0122                    |
//|                         Copyright 2020                           |
//|                     www.expert-advisor.com                       |
//+------------------------------------------------------------------+

#property copyright "Sirocool"
#property link      "http://www.expert-advisor.com/forum/members/sirocool.html"

//#property icon "\\Images\\Icon\\Shark.ico"

extern string  a_SHARK_SETTINGS ="~~* RSI Settings *~~";

extern int Fast_Length = 14;
extern double Over_Up = 30;
extern double Over_Dn = 70;


extern ENUM_APPLIED_PRICE SOURCE = PRICE_CLOSE;

extern string  b_SHARK_SETTINGS ="~~* RSI Settings Styl *~~";



extern string  c_SHARK_SETTINGS ="~~* RSI Settings Alert *~~";

extern bool ShowArrows    = true;


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers  3

#property indicator_minimum 0
#property indicator_maximum 100

//+------------------------------------------------------------------+
//| ENUM_APPLIED_PRICE                                               |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string PriceTypeToString(int pt)
  {
   string answer;
   switch(pt)
     {
      case 0:
         answer = "Close"    ;
         break;
      case 1:
         answer = "Open"     ;
         break;
      case 2:
         answer = "High"     ;
         break;
      case 3:
         answer = "Low"      ;
         break;
      case 4:
         answer = "Median"   ;
         break;
      case 5:
         answer = "Typical"  ;
         break;
      case 6:
         answer = "Wighted"  ;
         break;
      default:
         answer = "Invalid price field requested";
         Alert(answer);
     }
   return(answer);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| IndicatorShortName                                               |
//+------------------------------------------------------------------+
string Name ="SHARK_RSI_CLASSIC_V.21"+"( "+ Fast_Length +","+PriceTypeToString(SOURCE)+","+ Over_Up+","+Over_Dn+")";
int windowIndex=WindowFind(Name),maxArrows,maxLine;

//==================================== rectangle names
string NameTopLev=windowIndex+"LevelTop";       //50 -
string NameWaitUp=windowIndex+"LevelWaitTop";   // 55
string NameWaitLo=windowIndex+"LevelWaitBot";   //-45
string NameBotLev=windowIndex+"LevelBot";       //30




double SHARK_BUFFER_M[],SHARK_BUFFER_ARROW_UP[],SHARK_BUFFER_ARROW_DN[];
bool ExtParameters=false, initFinished=false;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(3);
   IndicatorDigits(Digits+1);//max. 2

   SetIndexBuffer(0,SHARK_BUFFER_M,INDICATOR_DATA); // RSI_LINIE
   SetIndexStyle(0,DRAW_LINE,EMPTY,1,clrRoyalBlue);
   SetIndexDrawBegin(0,Fast_Length);
   SetIndexLabel(0,"RSI");

   SetIndexBuffer(1,SHARK_BUFFER_ARROW_UP,INDICATOR_DATA);
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1,clrForestGreen);
   SetIndexArrow(1, 241);
   SetIndexLabel(1,NULL);

   SetIndexBuffer(2,SHARK_BUFFER_ARROW_DN,INDICATOR_DATA);
   SetIndexStyle(2, DRAW_ARROW, EMPTY,1,clrFireBrick);
   SetIndexArrow(2, 242);
   SetIndexLabel(2,NULL);


   if(Fast_Length<=1)
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;

   return(INIT_SUCCEEDED);

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   _DeleteArrows();
   ObjectDelete("SoldLine");
   ObjectDelete("BuyLine");
   ObjectDelete("SellLine");
   ObjectDelete("BoughtLine");

//ObjectsDeleteAll();
//ObjectDelete();
//deleteArrows();
   return(0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   _Overlines(Over_Up,Over_Dn);



   int counted_bars=IndicatorCounted(),limit,i;

   if(counted_bars<0)
      return(-1);
   if(counted_bars>0)
      counted_bars--;

   limit=MathMin(Bars-counted_bars,Bars-1);

   for(i = limit; i >= 0 && !IsStopped(); i--)
     {
      SHARK_BUFFER_M[i] = iRSI(Symbol(),Period(),Fast_Length,SOURCE,i);
      double Lower=iFractals(NULL,0,MODE_LOWER,i);
      double Upper=iFractals(NULL,0,MODE_UPPER,i);

      //+------------------------------------------------------------------+
      //| SHARK_SHOW_ARROWS                                                |
      //+------------------------------------------------------------------+
      if(ShowArrows)
        {
         //+------------------------------------------------------------------+
         //| SHARK_SHORT_SIGNAL                                               |
         //+------------------------------------------------------------------+
         if((SHARK_BUFFER_M[i] < Over_Dn) && (SHARK_BUFFER_M[i+1] > Over_Dn))
           {
            SHARK_BUFFER_ARROW_DN[i+1] = Upper+95;
            DrawArrow(i+1,"Dn",Upper);
           }
         //+------------------------------------------------------------------+
         //| SHARK_LONG_SIGNAL                                                |
         //+------------------------------------------------------------------+
         if((SHARK_BUFFER_M[i] > Over_Up) && (SHARK_BUFFER_M[i+1] < Over_Up))
           {
            SHARK_BUFFER_ARROW_UP[i+1] = Lower+5;
            DrawArrow(i+1,"Up",Lower);
           }
        }
      //+------------------------------------------------------------------+
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Extras                                                           |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Overline 70 / 30                                                 |
//+------------------------------------------------------------------+
void _Overlines(int Up, int Dn)
  {
   if(initFinished==false)
     {
      IndicatorShortName(Name);
      windowIndex=WindowFind(Name);

      if(windowIndex<0)
        {
         Print("Can\'t find window");
         return;
        }
      ObjectCreate("SoldLine",OBJ_HLINE,windowIndex,0,Up);
      ObjectSet("SoldLine",OBJPROP_COLOR,clrGreen);
      ObjectSet("SoldLine",OBJPROP_WIDTH,1);
      ObjectSet("SoldLine",OBJPROP_STYLE,STYLE_DOT);

      ObjectCreate("BuyLine",OBJ_HLINE,windowIndex,0,Up+10);
      ObjectSet("BuyLine",OBJPROP_COLOR,C'128,128,128');
      ObjectSet("BuyLine",OBJPROP_WIDTH,1);
      ObjectSet("BuyLine",OBJPROP_STYLE,STYLE_DOT);

      ObjectCreate("SellLine",OBJ_HLINE,windowIndex,0,Dn-10);
      ObjectSet("SellLine",OBJPROP_COLOR,C'128,128,128');
      ObjectSet("SellLine",OBJPROP_WIDTH,1);
      ObjectSet("SellLine",OBJPROP_STYLE,STYLE_DOT);

      ObjectCreate("BoughtLine",OBJ_HLINE,windowIndex,0,Dn);
      ObjectSet("BoughtLine",OBJPROP_COLOR,clrRed);
      ObjectSet("BoughtLine",OBJPROP_WIDTH,1);
      ObjectSet("BoughtLine",OBJPROP_STYLE,STYLE_DOT);
     }
  }

//+------------------------------------------------------------------+
//| Show Arrows                                                      |
//+------------------------------------------------------------------+
void DrawArrow(int i,string type, double grap)
  {
   maxArrows++;
   ObjectCreate("RSISignal"+maxArrows,OBJ_ARROW,0,Time[i],0);
   if(type=="Dn")
     {
      ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,grap);
      ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,242);
      ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrRed);
     }
   else
      if(type=="Up")
        {
         ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,grap);
         ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,241);
         ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrGreen);
        }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void _DeleteArrows()
  {
   while(maxArrows>0)
     {
      ObjectDelete("RSISignal"+maxArrows);
      maxArrows--;
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+