FXCM Forex Trading

Waddah Attar Strong Level

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Waddah Attar Strong Level

Postby Alexander.Gettinger » Tue Jun 01, 2010 1:18 am

viewtopic.php?f=27&t=999

Waddah_Attar_Strong_Level.png


Code: Select all
function Init()
    indicator:name("Waddah Attar Strong Level");
    indicator:description("Waddah Attar Strong Level");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
   
    indicator.parameters:addBoolean("DrawDay", "DrawDay", "No description", true);
    indicator.parameters:addBoolean("DrawWeek", "DrawWeek", "No description", true);
    indicator.parameters:addBoolean("DrawMonth", "DrawMonth", "No description", true);
    indicator.parameters:addBoolean("BackTest", "BackTest", "No description", true);

    indicator.parameters:addColor("Day_Up_clr", "Day up color", "Day up color", core.rgb(255, 0, 0));
    indicator.parameters:addColor("Day_Dn_clr", "Day down color", "Day down color", core.rgb(255, 0, 0));
    indicator.parameters:addColor("Week_Up_clr", "Week up color", "Week up color", core.rgb(0, 255, 0));
    indicator.parameters:addColor("Week_Dn_clr", "Week down color", "Week down color", core.rgb(0, 255, 0));
    indicator.parameters:addColor("Month_Up_clr", "Month up color", "Month up color", core.rgb(0, 0, 255));
    indicator.parameters:addColor("Month_Dn_clr", "Month down color", "Month down color", core.rgb(0, 0, 255));
end

local first;
local source = nil;
local DrawDay;
local DrawWeek;
local DrawMonth;
local BackTest;

function Prepare()
    source = instance.source;
    DrawDay=instance.parameters.DrawDay;
    DrawWeek=instance.parameters.DrawWeek;
    DrawMonth=instance.parameters.DrawMonth;
    BackTest=instance.parameters.BackTest;
    first=source:first()+1;
    local name = profile:id() .. "(" .. source:name() ..")";
    instance:name(name);
    DayUp = instance:addStream("DayUp", core.Line, name .. ".DayUp", "DayUp", instance.parameters.Day_Up_clr, first);
    DayDn = instance:addStream("DayDn", core.Line, name .. ".DayDn", "DayDn", instance.parameters.Day_Dn_clr, first);
    WeekUp = instance:addStream("WeekUp", core.Line, name .. ".WeekUp", "WeekUp", instance.parameters.Week_Up_clr, first);
    WeekDn = instance:addStream("WeekDn", core.Line, name .. ".WeekDn", "WeekDn", instance.parameters.Week_Dn_clr, first);
    MonthUp = instance:addStream("MonthUp", core.Line, name .. ".MonthUp", "MonthUp", instance.parameters.Month_Up_clr, first);
    MonthDn = instance:addStream("MonthDn", core.Line, name .. ".MonthDn", "MonthDn", instance.parameters.Month_Dn_clr, first);
end


function Update(period, mode)
    if (period>first) then
     local Dc1=nil;
     local Dc2=nil;
     local Dc3=nil;
     local Wc1=nil;
     local Wc2=nil;
     local Wc3=nil;
     local Mc1=nil;
     local Mc2=nil;
     local Mc3=nil;
     
     local d,t;
     d,t=source:date(period);
     local table=core.dateToTable(d);
     local LastD=table.year*372+table.month*31+table.day;
     local LastM=table.year*12+table.month;
     local LastWD=table.wday;
     
     local shift=period;
     while shift>first and Mc3==nil do
      local d1,t1;
      d1,t1=source:date(shift);
      local table1=core.dateToTable(d1);
      local CurD=table1.year*372+table1.month*31+table1.day;
      local CurM=table1.year*12+table1.month;
      local CurWD=table1.wday;
     
      if Dc1==nil and CurD~=LastD then
       Dc1=source.close[shift];
       LastD=CurD;
      end
      if Dc1~=nil and Dc2==nil and CurD~=LastD then
       Dc2=source.close[shift];
       LastD=CurD;
      end
      if Dc2~=nil and Dc3==nil and CurD~=LastD then
       Dc3=source.close[shift];
       LastD=CurD;
      end
     
      if Wc1==nil and CurWD>LastWD then
       Wc1=source.close[shift];
       LastWD=CurWD;
      end
      if Wc1~=nil and Wc2==nil and CurWD>LastWD then
       Wc2=source.close[shift];
       LastWD=CurWD;
      end
      if Wc2~=nil and Wc3==nil and CurWD>LastWD then
       Wc3=source.close[shift];
       LastWD=CurWD;
      end
      LastWD=CurWD;
     
      if Mc1==nil and CurM~=LastM then
       Mc1=source.close[shift];
       LastM=CurM;
      end
      if Mc1~=nil and Mc2==nil and CurM~=LastM then
       Mc2=source.close[shift];
       LastM=CurM;
      end
      if Mc2~=nil and Mc3==nil and CurM~=LastM then
       Mc3=source.close[shift];
       LastM=CurM;
      end
     
      shift=shift-1;
     end
     
     if Dc3~=nil and DrawDay==true then
      local dc=Dc1-Dc2;
      if dc==0 then
       dc=Dc1-Dc3;
      end
      if dc==0 then
       dc=Dc1;
      end
      DayUp[period]=Dc1+dc;
      DayDn[period]=Dc1-dc;
     end
     
     if Wc3~=nil and DrawWeek==true then
      dc=Wc1-Wc2;
      if dc==0 then
       dc=Wc1-Wc3;
      end
      if dc==0 then
       dc=Wc1;
      end
      WeekUp[period]=Wc1+dc;
      WeekDn[period]=Wc1-dc;
     end
     
     if Mc3~=nil and DrawMonth==true then
      dc=Mc1-Mc2;
      if dc==0 then
       dc=Mc1-Mc3;
      end
      if dc==0 then
       dc=Mc1;
      end
      MonthUp[period]=Mc1+dc;
      MonthDn[period]=Mc1-dc;
     end
     
     if BackTest~=true then
      for i=first,period-1,1 do
       DayUp[i]=DayUp[period];
       DayDn[i]=DayDn[period];
       WeekUp[i]=WeekUp[period];
       WeekDn[i]=WeekDn[period];
       MonthUp[i]=MonthUp[period];
       MonthDn[i]=MonthDn[period];
      end
     end
     
     
    end
end
Attachments
Waddah_Attar_Strong_Level.lua
(5.23 KiB) Downloaded 492 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2669
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Waddah Attar Strong Level

Postby Apprentice » Wed Jan 11, 2017 6:14 am

Indicator was revised and updated.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 16136
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Custom Indicators

Who is online

Users browsing this forum: Apprentice, Bing [Bot], Fernas and 10 guests